<template>
  <div class="edit-audit-messagebox">
    <el-dialog
      title="题目审核"
      :visible.sync="VisibleEditAudit"
      width="30%"
      :before-close="close"
    >
      <el-form ref="editAuditForm" :model="editAuditForm">
        <el-radio v-model="editAuditForm.radio" label="1">通过</el-radio>
        <el-radio v-model="editAuditForm.radio" label="2">拒绝</el-radio><br />
        <el-input
          type="textarea"
          :rows="3"
          placeholder="请输审核意见"
          v-model="editAuditForm.textarea"
        >
        </el-input>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="close">取 消</el-button>
        <el-button type="primary" @click="getEditAuditOpinions"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { editAuditOpinions } from '@/assets/api/base/audit.js';
export default {
  name: '',
  props: {
    VisibleEditAudit: {
      type: Boolean
    },
    id: {
      type: [String, Number, Object]
    }
  },
  data: function() {
    return { editAuditForm: { radio: '1', textarea: '' } };
  },
  created() {},
  methods: {
    close() {
      this.$emit('CloseEditAudit');
    },
    async getEditAuditOpinions() {
      try {
        const reqInfo = {
          id: this.id,
          chkState: parseInt(this.editAuditForm.radio),
          chkRemarks: this.editAuditForm.textarea
        };
        await editAuditOpinions(this.id, reqInfo);
        this.$message.success('审核完成');
        this.$emit('CloseEditAudit');
      } catch (err) {
        this.$message.error('审核意见获取失败');
      }
    }
  }
};
</script>

<style lang="less" scoped>
.edit-audit-messagebox {
  .el-radio {
    margin-bottom: 20px;
  }
  .el-input {
    max-height: 50px;
  }
}
</style>
